<template>
  <div class="leftMenu">
     <div class="title_img">
     	 <img src="../../assets/logo.jpg">
     </div>
     <el-menu :default-active="onRoutes" class="el-menu-vertical-demo" theme="dark" unique-opened router>
            <template v-for="item in items">
                <template v-if="item.subs">
                    <el-submenu :index="item.index">
                        <template slot="title"><i :class="item.icon"></i>{{ item.title }}</template>
                        <el-menu-item v-for="(subItem,i) in item.subs" :key="i" :index="subItem.index">{{ subItem.title }}
                        </el-menu-item>
                    </el-submenu>
                </template>
                <template v-else>
                    <el-menu-item :index="item.index">
                        <i :class="item.icon"></i>{{ item.title }}
                    </el-menu-item>
                </template>
            </template>
     </el-menu>
  </div>
</template>

<script>
export default {
  data () {
    return {
       items: [
                    {
                        icon: 'el-icon-setting',
                        index: 'readme',
                        title: '自述'
                    },
                    {
                        icon: 'el-icon-menu',
                        index: '2',
                        title: '博客文章管理',
                        subs: [
                            {
                                index: '/writeArticle',
                                title: '写博客'
                            },
                            {
                                index: '/articleList',
                                title: '博客文章列表'
                            }
                        ]
                    },
                    {
                        icon: 'el-icon-menu',
                        index: '3',
                        title: '新闻文章管理',
                        subs: [
                            {
                                index: '/writeNewArticle',
                                title: '写新闻'
                            },
                            {
                                index: '/articleNewList',
                                title: '新闻列表'
                            }
                        ]
                    },
                   
                ]
    }
  }
}
</script>


<style lang="stylus" scoped>
.leftMenu
	flex 0 0 250px
	background #2f4050
	color #fff
	min-height calc(100vh);
	.title_img
		width 65px
		margin 30px 0 40px 20px
		img
			width 100%
			height 65px
			border-radius 50%
	.el-menu--dark
		background #2f4050
</style>
